package com.bdqn.spark.chapter05.value

import org.apache.spark.{SparkConf, SparkContext}

object Spark02_RDD_Operator_Transform_Test {
  def main(args: Array[String]): Unit = {
    val conf: SparkConf = new SparkConf()
      .setMaster("local[*]")
      .setAppName("practise")
    val sc: SparkContext = new SparkContext(conf)

    val sourceRDD = sc.makeRDD(List(1, 4, 2, 3), 3)
    // 需求：获取每个数据分区的最大值
    // [1 2]  -> 2
    // [3 4]  -> 4

    sourceRDD.mapPartitions(
      iter => {
        List(iter.max).toIterator
      }
    ).collect.foreach(println)


    sc.stop()
  }
}
